package com.itheima.service.impl;

import com.itheima.domain.User;
import com.itheima.mapper.UserMapper;
import com.itheima.service.UserService;
import com.itheima.utils.MapperUtils;
import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;

import java.io.IOException;
import java.io.InputStream;
import java.util.List;


public class UserServiceImpl implements UserService {


    public List<User> findAll() {
       SqlSession session = MapperUtils.getSqlSession();

//        4.获取mapper代理对象
        UserMapper userDao = session.getMapper(UserMapper.class);

//        5.调用接口中的方法  (接口直接调用方法)
        List<User> list = userDao.findAll();
        //提交事务
        MapperUtils.close(session);

        return list;
    }
}
